﻿//
// Created by francklinson on 2021/3/19.
//

#ifndef CPPPRIMERPLUSREADINGCODES_STOCK_H
#define CPPPRIMERPLUSREADINGCODES_STOCK_H

#include <string>

class Stock
{
private:

    std::string company;
    long shares; // stock nums
    double share_val; // stock price
    double total_val{}; // total stock price

    void set_tot()
    { total_val = shares * share_val; }

public:
    // init
    Stock(const std::string &co, long n = 0, double pr = 0.0);

    // default init
    Stock();

    //
    ~Stock();

    void buy(long num, double price);

    void sell(long num, double price);

    void update(double price);

    void show()const;

    const Stock & topVal(const Stock& s)const;

};  //

#endif //CPPPRIMERPLUSREADINGCODES_STOCK_H
